function AttFjGd() {
    this.form = this.InitForm();
    this.tab = this.InitTab();
    this.table = null;

    var year = $("#hidyear").val();
    var quarter = $("#hidquarter").val();
    $("#year").val(year);
    $("#quarter").val(quarter);

    var month = 3;//根据季度来设置月份
    if (quarter == 2) month = 6;
    if (quarter == 3) month = 9;
    if (quarter == 4) month = 12;
    $("#hidmonth").val(month);

    this.form.render('select');

    this.InitGrid();
    this.InitOrg();
}


AttFjGd.prototype.InitOrg = function () {
    var comboboxm = $("#orgid").ligerComboBox({
        valueField: 'orgid',
        textField: 'orgname',
        selectBoxWidth: 250,
        selectBoxHeight: 250,
        treeLeafOnly: false,
        valueFieldID: "hid",
        tree: {
            url: '../common/get_org_list?orgtype=0',
            checkbox: false,
            nodeWidth: 150,
            ajaxType: 'get',
            idFieldName: 'orgid',
            textFieldName: "orgname",
            idField: "orgid",
            parentIDField: "orgparentid"
        },
        onSelected: function (orgid, orgname) {// id为空值，name为选择的值
            $("#hidorgid").val(orgid);
            vWorksPay.searchlist();
        },
        width: 250
    });
    return comboboxm;
}

AttFjGd.prototype.InitTab = function () {
    var element;
    layui.use('element', function () {
        element = layui.element;

        element.on('tab(tabcontent)', function (data) {
            if (data.index == 1) {

            } else {
                //$("#hidorgid").val(0);
                //$("#hidorgsummaryid").val(0);
                //this.InitTableByBt(0,0);
            }
        });

    });
    return element;
}

AttFjGd.prototype.InitForm = function () {
    var form;
    layui.use('form', function () {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.on('select(year)', function (data) {
            $("#hidyear").val(data.value);
            form.render('select');
            vWorksPay.searchlist();
        });
        form.on('select(quarter)', function (data) {
            $("#hidquarter").val(data.value);
            form.render('select');
            vWorksPay.searchlist();
        });
        form.on('select(status)', function (data) {
            $("#hidstatus").val(data.value);
            form.render('select');
            vWorksPay.searchlist();
        });

        form.render();
    });
    return form;
}
AttFjGd.prototype.OpTab = function (tabindex, obj) {
    this.tab.tabChange('tabcontent', tabindex);
}

AttFjGd.prototype.InitGrid = function () {
    var _this = this;
    window.liger.remove("orgsuylist");
    if (_this.grid == null) {
        _this.grid = $("#orgsuylist").ligerGrid({
            checkbox: true,
            columns: [

                //{ display: '序号', width: 80, name: 'rowNum' },
                {display: '机构名称', width: 250, align: 'left', name: 'orgname', id: "orgname"},
                {display: '年', width: 100, name: 'year'},
                {
                    display: '季度', width: 100, name: 'quarter', render: function (rowdata, rowindex, value) {
                        var month = rowdata.month;
                        var quarter = rowdata.quarter;
                        var str = '';
                        switch (quarter) {
                            case null:
                            case '':
                            case undefined:
                                if (month == "1" || month == "2" || month == "3") {
                                    str = "第一季度";
                                }
                                if (month == "4" || month == "5" || month == "6") {
                                    str = "第二季度";
                                }
                                if (month == 7 || month == 8 || month == 9) {
                                    str = "第三季度";
                                }
                                if (month == 10 || month == 11 || month == 12) {
                                    str = "第四季度";
                                }
                                break;
                            case 1:
                                str = "第一季度";
                                break;
                            case 2:
                                str = "第二季度";
                                break;
                            case 3:
                                str = "第三季度";
                                break;
                            case 4:
                                str = "第四季度";
                                break;
                        }
                        return str;
                    }
                },
                {
                    display: '状态', width: 120, name: 'status', render: function (rowdata, rowindex, value) {
                        var status = rowdata.status;
                        if (!rowdata.usercount || rowdata.usercount <= 1) {
                            return '';
                        }
                        var str = '';
                        switch (status) {
                            case null:
                            case '':
                            case undefined:
                                str = "未填报";
                                break;
                            case 0:
                                str = '<span style="color:#B8E986">填报<span>';
                                break;
                            case 1:
                                str = "提交";
                                break;
                            case 2:
                                str = "归档";
                                break;
                            case 3:
                                str = "驳回";
                                break;
                            case 4:
                                str = "审核通过";
                                break;
                        }
                        return str;
                    }
                },
                {
                    display: '操作', width: 100, name: 'userid', render: function (rowdata, rowindex, value) {
                        var html = '';
                        if (rowdata.status != null && typeof(rowdata.status) != 'undefined') {
                            html += ' <img class="btn-img" onclick="vWorksPay.SkipDetail(' + rowdata.orgid + ',' + rowdata.orgsummaryid + ',\'' + rowdata.orgname + '\',' + rowdata.year + ',' + rowdata.month + ')" src="' + ctxStatic + '/images/button/detail.png" lay-event="detail" alt="详情" title="详情">';
                        }
                        if (rowdata.usercount - 1 > 0 && typeof(rowdata.status) == 'undefined') {

                            html += ' <img class="btn-img" onclick="vWorksPay.createatttb(' + rowdata.orgid + ',' + rowdata.year + ',' + rowdata.month + ')" src="' + ctxStatic + '/images/index/yaosu.png" lay-event="shengcheng" alt="计算补助" title="计算补助">';
                        }
                        if (rowdata.status == 4) {
                            html += '<img class="btn-img" onclick="vWorksPay.updatestatus(' + rowdata.orgsummaryid + ',' + rowdata.orgid + ',2)" src="' + ctxStatic + '/images/button/guidang.png" lay-event="guidang" alt="归档" title="归档">';
                            html += '<img class="btn-img" onclick="vWorksPay.updatestatus(' + rowdata.orgsummaryid + ',' + rowdata.orgid + ',3)" src="' + ctxStatic + '/images/button/bohui.png" lay-event="bohui" alt="驳回" title="驳回">';
                        }
                        if (rowdata.status != null && typeof(rowdata.status) != 'undefined') {
                            if ($("#hidAdmin").val() == "true") {
                                html += '<img class="btn-img" onclick="vWorksPay.updatestatus(' + rowdata.orgsummaryid + ',' + rowdata.orgid + ',3)" src="' + ctxStatic + '/images/button/bohui.png" lay-event="bohui" alt="驳回" title="驳回">';
                            }
                        }
                        return html;
                    }
                }
            ],
            pageSize: 30,
            url: "get_org_work_list" + '?time=' + new Date().getTime(),
            delayLoad: false,            //初始化时是否加载,为true时,不加载,为false时,则加载
            sortName: null,
            dataAction: 'server',
            parms: {
                year: $("#hidyear").val(),
                month: $("#hidmonth").val(),
                orgid: $("#hidorgid").val()
            },
            sortOrder: null,
            sourceObj: _this.grid,
            root: 'items',                       //数据源字段名
            record: 'countRecord',                    //数据源记录数字段名
            pageParmName: 'CurrentPage',               //页索引参数名，(提交给服务器)
            pagesizeParmName: 'PageSize',        //页记录数参数名，(提交给服务器)
            data: {},
            width: "100%",
            height: '100%',
            heightDiff: 0,
            rowHeight: 28,
            onBeforeCheckRow: function (checked, data, rowid, rowdata) {

            },
            onBeforeCheckAllRow: function (checked, element) {


            },
            onSuccess: function (rowdata, rowindex) {
                if (rowdata.status > 0) {
                    alert(rowdata.msg)
                }
            },
            alternatingRow: true,
            border: 0,
            usePager: false,
            tree: {
                columnId: "orgname",
                idField: "orgid",
                parentIDField: "orgparentid"

            }
        })
    }
}


AttFjGd.prototype.InitOrgSuyTable = function () {
    var table;
    var _this = this;
    layui.use('table', function () {
        table = layui.table;
        table.render({
            elem: '#orgsuylist'
            , height: $(window).height() - 230
            , url: 'get_org_work_list' // 数据接口
            , page: true // 开启分页
            , limit: 30
            , id: 'orgsuylist'
            , method: "post"
            , cols: [[ // 表头
                {type: 'checkbox'}
                //{field : 'rowNum',title : '序号',width : 70,align : 'center'}
                , {field: 'orgname', title: '单位名称', width: 250, align: 'center'}
                , {field: 'year', title: '年', width: 100, align: 'center'}
                , {field: 'quarter', title: '季度', width: 120, align: 'center'}
                // , {field: 'month', title: '月份', width: 120, align: 'center'}
                // , {field: 'usercount', title: '部门人数', width: 100, align: 'center'}
                , {field: 'status', title: '状态', width: 120, align: 'center'}
                , {title: '操作', width: 150, align: 'center', toolbar: '#operateorgsuy'}
            ]]
            , request: {
                type: 'post'
            }
            , page: false
            , where: {
                year: $("#hidyear").val(),
                month: $("#hidmonth").val(),
                status: $("#hidstatus").val()
            }
            , even: true //开启隔行背景
            , done: function (res, page, count) {
                var dataarr = res.data;
                $("[data-field='status']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                                $(this).text("未填报");
                                break;
                            case '':
                                $(this).text("未填报");
                                break;
                            case '0':
                                $(this).text("填报");
                                break;
                            case '1':
                                $(this).text("提交");
                                break;
                            case '2':
                                $(this).text("归档");
                                break;
                            case '3':
                                $(this).text("驳回");
                                break;
                            case  '4':
                                $(this).text("审核通过");
                                break;

                        }
                    }
                })

                $("[data-field='sfqq']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        if (text == "0") {
                            $(this).text("否");
                        }
                        else {
                            $(this).text("是");
                        }
                    }
                })

                $("[data-field='quarter']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                            case '':
                                var month = dataarr[index - 1].month;
                                if (month == 1 || month == 2 || month == 3) {
                                    $(this).text("第一季度");
                                }
                                if (month == 4 || month == 5 || month == 6) {
                                    $(this).text("第二季度");
                                }
                                if (month == 7 || month == 8 || month == 9) {
                                    $(this).text("第三季度");
                                }
                                if (month == 10 || month == 11 || month == 12) {
                                    $(this).text("第四季度");
                                }
                                break;
                            case '1':
                                $(this).text("第一季度");
                                break;
                            case '2':
                                $(this).text("第二季度");
                                break;
                            case '3':
                                $(this).text("第三季度");
                                break;
                            case '4':
                                $(this).text("第四季度");
                                break;
                        }
                    }
                })


                // var data = res.data;
                var allck = true;
                for (i = 0; i < dataarr.length; i++) {
                    if (dataarr[i].status != 1 || dataarr[i].status == null) {
                        allck = false;
                        break;
                    }
                }
                if (!allck) {
                    $(".layui-table-header").find("input[name = 'layTableCheckbox'][lay-filter='layTableAllChoose']").each(function () {
                        $(this).attr("disabled", 'disabled').next().removeClass("layui-form-checked");
                        _this.form.render('checkbox');
                    });
                }
                var i = 0;
                $(".layui-table-body.layui-table-main").find("input[name='layTableCheckbox']").each(function () {
                    if (res.data[i].status != 1) {//关键点如果当前行数据中score包含57那么就不可选
                        $(this).attr("disabled", 'disabled').removeAttr("checked");
                        _this.form.render('checkbox');
                    }
                    i++;
                });

                i = 0;
                $(".layui-table-fixed.layui-table-fixed-l").find(".layui-table-body").find("input[name='layTableCheckbox']").each(function () {
                    if (res.data[i].status != 1) {//关键点如果当前行数据中score包含57那么就不可选
                        $(this).attr("disabled", 'disabled').removeAttr("checked");
                        _this.form.render('checkbox');
                    }
                    i++;
                });


            }

        });

        //监听工具条
        table.on('tool(orgsuylist)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                $("#hidorgid").val(data.orgid);
                $("#hidorgsummaryid").val(data.orgsummaryid);

                _this.OpTab(2, data);

                var quarter = "1";
                if (data.month == 4 || data.month == 5 || data.month == 6) quarter = 2;
                if (data.month == 7 || data.month == 8 || data.month == 9) quarter = 3;
                if (data.month == 10 || data.month == 11 || data.month == 12) quarter = 4;
                $("#hidquarter").val(quarter);
                $("#table_title").html("房山公安分局" + data.orgname + " " + data.year + " 年第" + quarter + " 季工作性津贴");

                _this.table = _this.InitTableByBt(data.orgid, data.orgsummaryid);
            } else if (obj.event === 'guidang') {
                top.mylayui.confirm('确定要归档吗？', {icon: 0}, function (index) {
                    top.mylayui.close(index);
                    vWorksPay.updatestatus(data.orgsummaryid, data.orgid, 2);
                })
            } else if (obj.event === 'bohui') {
                top.mylayui.confirm('确定要驳回吗？', {icon: 0}, function (index) {
                    top.mylayui.close(index);
                    vWorksPay.updatestatus(data.orgsummaryid, data.orgid, 3);
                })
            } else if (obj.event === 'shengcheng') {
                vWorksPay.createatttb(data.orgid, data.year, data.month);
            }
        });

    });

    return table;
}

AttFjGd.prototype.SkipDetail = function (orgid, orgsummaryid, orgname, year, month) {
    $("#hidorgid").val(orgid);
    $("#hidorgsummaryid").val(orgsummaryid);
    var quarter = "1";
    if (month == 4 || month == 5 || month == 6) quarter = 2;
    if (month == 7 || month == 8 || month == 9) quarter = 3;
    if (month == 10 || month == 11 || month == 12) quarter = 4;
    $("#hidquarter").val(quarter);
    $("#hidmonth").val(month);
    this.OpTab(2);
    $("#table_title").html("房山公安分局" + orgname + " " + year + " 年第" + quarter + " 季度工作性津贴");
    this.table = this.InitTableByBt(orgid, orgsummaryid);
}


AttFjGd.prototype.querydetail = function () {
    if ($("#hidorgid").val() == "" || $("#hidorgid").val() == "0") {
        top.mylayui.msg('请先点机构列表后面详情按钮，再点击查询', {icon: 0});
        return;
    }


    this.InitTableByBt($("#hidorgid").val(), $("#hidorgsummaryid").val());
}

AttFjGd.prototype.InitTableByBt = function (orgid, orgsummaryid) {
    var quarter = $("#hidquarter").val();
    var month1 = "一月";
    var month2 = "二月";
    var month3 = "三月";
    if (quarter == 2) {
        month1 = "四月";
        month2 = "五月";
        month3 = "六月"
    }
    if (quarter == 3) {
        month1 = "七月";
        month2 = "八月";
        month3 = "九月"
    }
    if (quarter == 4) {
        month1 = "十月";
        month2 = "十一月";
        month3 = "十二月"
    }
    var table;
    var _this = this;
    layui.use('table', function () {
        table = layui.table;
        table.init('attfjgdlist', {
            height: $(window).height() - 205
            , url: 'get_work_dept_list' // 数据接口
            , page: true // 开启分页
            , limit: 40
            , id: 'attfjgdlist'
            , limits: [20, 40, 80, 100]
            , cols: [
                [
                    {title: '扣减情况', align: 'center', colspan: 8}
                    , {title: '增加情况', align: 'center', colspan: 4}
                ],
                [ // 表头
                    {field: 'realname', title: '姓名', width: 80, align: 'center'}
                    , {field: 'orgname', title: '部门', width: 120, align: 'center'}
                    , {field: 'cardno', title: '身份证号', width: 120, align: 'center'}
                    , {field: 'downreason', title: '原因', width: 120, align: 'center', edit: 'text'}
                    , {field: 'workpernum1', title: '' + month1 + '', width: 80, align: 'center'}
                    , {field: 'workpernum2', title: '' + month2 + '', width: 80, align: 'center'}
                    , {field: 'workpernum3', title: '' + month3 + '', width: 80, align: 'center'}
                    , {field: 'workpernumsum', title: '合计', width: 180, align: 'center'}
                    , {field: 'realname', title: '姓名', width: 80, align: 'center'}
                    , {field: 'cardno', title: '身份证号', width: 120, align: 'center'}
                    , {field: 'upreason', title: '原因', width: 120, align: 'center'}
                    , {field: 'upmoney', title: '金额', width: 120, align: 'center'}
                    , {field: 'status', title: '状态', width: 120, align: 'center'}
                ]
            ]
            , method: "post"
            , request: {
                type: 'post'
            }
            , where: {
                year: $("#hidyear").val(),
                month: $("#hidmonth").val(),
                quarter: quarter,
                orgid: orgid,
                realname: $("#realname").val(),
                orgsummaryid:orgsummaryid
            }
            , done: function (res, page, count) {
                var dataarr = res.data;

                $("[data-field='downreason']").children().each(function (index) {
                    $($(this)[0]).addClass('cellColor');
                })

                $("[data-field='status']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                                $(this).text("未填报");
                                break;
                            case '':
                                $(this).text("未填报");
                                break;
                            case '0':
                                $(this).text("填报");
                                break;
                            case '1':
                                $(this).text("确认");
                                break;
                            case '2':
                                $(this).text("归档");
                                break;
                            case '3':
                                $(this).text("驳回");
                                break;
                            case '4':
                                $(this).text("审核通过");
                                break;
                        }
                    }
                })

                $("[data-field='sfqq']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        if (text == "0") {
                            $(this).text("否");
                        }
                        else {
                            $(this).text("是");
                        }
                    }
                })
            }
        });


        //监听工具条
        table.on('tool(attfjgdlist)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                vWorksPay.openadddetail(obj.data.attsummaryid, obj.data.orgsummaryid);
            }
        });


    })

    return table;


}

AttFjGd.prototype.save = function () {
    var tabledataJson = this.table.cache;
    var quarter = $("#hidquarter").val();
    var year = $("#year").val();
    // var month = $("#month").val();
    tabledataJson['year'] = year;
    // tabledataJson['month']=month;
    tabledataJson['quarter'] = quarter;
    tabledataJson = JSON.stringify(tabledataJson);
    tabledataJson = tabledataJson.replace(/LAY_TABLE_INDEX/g, 'lay_TABLE_INDEX');
    $.ajax({
        type: "POST",
        url: "update_work_pay",
        contentType: 'application/json',
        data: tabledataJson,
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                top.mylayui.msg(data.msg, {icon: 1});
                vWorksPay.querydetail();
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
        },
        complete: function (XHR) {

        },
        error: function () {

        }
    });
}

AttFjGd.prototype.createatttb = function (orgid, year, month) {

    var orgids = "";
    var rows = $("#orgsuylist").ligerGrid().getSelecteds();
    for (var i = 0; i < rows.length; i++) {
        orgids += rows[i].orgid + ","
    }
    if (orgids == "") {
        orgids = orgid;
    }


    top.ShowZheZhao();
    $.ajax({
        type: "POST",
        url: "create_work_pay",
        data: {orgid: orgids, year: year, month: month},
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                top.mylayui.msg(data.msg, {icon: 1});
                vWorksPay.searchlist();
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();
        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


AttFjGd.prototype.addresult = function (result, msg) {
    if (result > 0) {
        top.mylayui.msg('操作成功', {icon: 1});
        top.mylayui.closeAll('iframe');
    }
    else {
        if (msg) {
            top.mylayui.msg(msg, {icon: 0});
        } else {
            top.mylayui.msg('操作失败', {icon: 0});
        }
    }
}

AttFjGd.prototype.searchtable = function () {
    this.table.reload('attfjgdlist', {
        page: {
            curr: 1 //重新从第 1 页开始
        }
        , where: {
            year: $("#year").val(),
            month: $("#month").val(),
            orgid: $("#orgid").val()
        }
    });
}

AttFjGd.prototype.searchtableorgsuy = function () {
    this.orgsuytable.reload('orgsuylist', {
        page: {
            curr: 1 //重新从第 1 页开始
        }
        , page: false
        , where: {
            year: $("#hidyear").val(),
            month: $("#hidmonth").val(),
            status: $("#hidstatus").val()
        }
    });
}

AttFjGd.prototype.searchlist = function () {
    var month = 3;//根据季度来设置月份
    var quarter = $("#hidquarter").val();
    if (quarter == 2) month = 6;
    if (quarter == 3) month = 9;
    if (quarter == 4) month = 12;
    $("#hidmonth").val(month);

    this.grid.setOptions({
        newPage: 1, parms: {
            Method: "",
            year: $("#hidyear").val(),
            month: $("#hidmonth").val(),
            status: $("#hidstatus").val(),
            orgid: $("#hidorgid").val()
        }
    });
    this.grid.loadData();
}


AttFjGd.prototype.attrgd = function () {
    top.mylayui.confirm('确定要归档吗？', {icon: 0}, function () {
        $.ajax({
            type: "POST",
            url: "attr_fjgd",
            data: {
                year: $("#year").val(),
                month: $("#month").val(),
                orgid: $("#orgid").val()
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    top.mylayui.msg(data.msg, {icon: 1});
                    vWorksPay.searchtable();
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
            },
            complete: function (XHR) {

            },
            error: function () {

            }
        });

    })
}


AttFjGd.prototype.exportexcel = function () {
    if ($("#hidorgid").val() == "" || $("#hidorgid").val() == "0") {
        top.mylayui.msg('请先点机构列表后面详情按钮，再点击查询', {icon: 0});
        return;
    }
    top.ShowZheZhao();
    $.ajax({
        type: "POST",
        url: "export_excel",
        data: {
            year: $("#year").val(),
            month: $("#hidmonth").val(),
            quarter: $("#hidquarter").val(),
            orgid: $("#hidorgid").val(),
            orgsummaryid: $("#hidorgsummaryid").val()
        },
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                //top.mylayui.msg(data.msg, {icon: 1});
                //alert(data.msg);
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();

        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


AttFjGd.prototype.exportexcelall = function () {

    top.ShowZheZhao();
    $.ajax({
        type: "POST",
        url: "export_excel_all",
        data: {
            year: $("#hidyear").val(),
            quarter: $("#hidquarter").val(),
            month: $("#hidmonth").val()
        },
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                //top.mylayui.msg(data.msg, {icon: 1});
                //alert(data.msg);
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();

        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


AttFjGd.prototype.updatestatus = function (orgsummaryid, orgid, status) {
    var year = $("#year").val();
    var quarter = $("#hidquarter").val();
    //var orgid = $("#hidorgid").val();
    var constr = '确定要归档吗？';
    if (status == 2) {
        constr = '确定要归档吗？';
    }
    else if (status == 3) {
        constr = '确定要驳回吗？';
    }
    top.mylayui.confirm(constr, {icon: 0}, function (index) {
        top.mylayui.close(index);

        $.ajax({
            type: "POST",
            url: "update_work_pay_status",
            data: {year: year, quarter: quarter, orgid: orgid, status: status},
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    top.mylayui.msg(data.msg, {icon: 1});
                    //vWorksPay.searchtableorgsuy();
                    vWorksPay.searchlist();
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
            },
            complete: function (XHR) {

            },
            error: function () {

            }
        });

    })


}


AttFjGd.prototype.updatestatusBm = function (orgids, status) {
    var year = $("#year").val();
    var quarter = $("#hidquarter").val();
    $.ajax({
        type: "POST",
        url: "update_work_pay_statusbm",
        data: {year: year, quarter: quarter,orgids: orgids, status: status},
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                top.mylayui.msg(data.msg, {icon: 1});
                //vWorksPay.searchtableorgsuy();
                vWorksPay.searchlist();
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
        },
        complete: function (XHR) {

        },
        error: function () {

        }
    });
}

AttFjGd.prototype.guidang = function () {
    var _this = this;
    top.mylayui.confirm('确定要归档吗？', {icon: 0}, function (index) {
        top.mylayui.close(index);
        var data = _this.grid.getCheckedRows();
        var length = data.length;
        if (length == 0) {
            top.mylayui.msg('请选择部门', {icon: 0});
            return;
        }
        var orgids = '';
        for (i = 0; i < length; i++) {
            var status = data[i].status;
            if(status == 4)//将可以归档的选择提报
                orgids += data[i].orgid + ',';
        }
        if (orgids.length == 0){
            top.mylayui.msg('所选部门不能归档', {icon: 0});
            return;
        }

        vWorksPay.updatestatusBm(orgids, 2);
    })
}

var vWorksPay = null;
$(function () {
    vWorksPay = new AttFjGd();
})